<template>
	<view>
		<view class='sign-record' style="padding: 0 20rpx">
		   <view class='list' >
		      <view class='item'>
		         <view class='listn'>
		            <view class='itemn acea-row row-between-wrapper' v-for="(itemn,indexn) in signList" :key="indexn">
		               <view>
		                  <view class='name line1'>{{itemn.title}}</view>
		                  <view class="c_9 f_22">{{getTimeAgo(itemn.updateTime)}}</view>
		               </view>
                   <view class="flex flex-col justify-end ">
                     <view v-if="itemn.type == 1" class='num font-color-red'>+{{itemn.integral}}积分</view>
                     <view v-if="itemn.type == 2" class='num font-color'>-{{itemn.integral}}积分</view>
                     <view class="c_9 f_22">剩余:{{itemn.balance || '??' }}积分</view>
                   </view> 
		               
		            </view>
		         </view>
		      </view>
		   </view>
		    <list-footer :loadtitle="loadtitle"></list-footer>
		</view>
	</view>
</template>

<script>
	import { getIntegralList } from '@/api/user.js';
	import { getTimeAgo } from '../../utils/index.js'
import listFooter from '../../components/listFooter/listFooter.vue';
	export default {
  components: { listFooter },
		data() {
			return {
				loading:false,
				    loadend:false,
				    loadtitle:'加载更多',
				    page:1,
				    limit:20,
				    signList:[],
					isAuto: false, //没有授权的不会自动授权
					isShowAuth: false //是否隐藏授权
			};
		},
		onLoad(){
      this.getList();
			
		},
		onReachBottom: function () {
      this.page++
		    this.getList();
		  },
		methods: {
			// 动态显示时间值
			getTimeAgo(dateTime) {
				console.log(dateTime)
				return getTimeAgo(dateTime)
			},
			  /**
			     * 获取签到记录列表
			    */
			    getList:function(){
			      let that=this;
			      if(that.loading) return;
			      if(that.loadend) return;
            that.loading = true;
            that.loadtitle = "";
			      getIntegralList({ page: that.page, limit: that.limit }).then(res=>{
              console.log(res, 'res-----')
			        let list = res.data.list;
			        let loadend = list.length < that.limit;
			        that.signList = that.signList.concat(list)
              that.$set(that,'signList',that.signList);
              that.loadend = loadend;
              that.loading = false;
              that.loadtitle = loadend ? "到底啦，没有数据了~" : "加载更多"
                }).catch(err=>{
              that.loading = false;
              that.loadtitle = '加载更多';
			      });
			    },
		}
	}
</script>

<style>
	.list{
		border-radius: 20rpx;
		background-color: #fff;
		overflow: hidden;
	}
 .sign-record{
	 margin: 20rpx auto;
 }
.sign-record .list .item .data{height:80rpx;line-height:80rpx;font-size:24rpx;color:#666;}
.sign-record .list .item .listn{ font-size:24rpx;color:#999;background-color: #fff;}
.sign-record .list .item .listn .itemn{
  border-bottom: 1rpx solid #f7f7f7;
  padding: 40rpx 24rpx;}
.sign-record .list .item .listn .itemn .name{width:390rpx;font-size:28rpx;color:#282828;margin-bottom:10rpx;}
.sign-record .list .item .listn .itemn .num{font-size:36rpx;font-family: 'Guildford Pro';color:#2A9F17;}
.font-color-red {color: #DF4B43!important}
</style>
